# coding=utf-8
import os, sys
from huza.util.buildui import build_uidir
from loguru import logger

os.environ['QT_API'] = 'pyqt5'  # tells QtPy to use PySide2


class Extra:
    debug = None
    egg = None
    proj = None

    def __init__(self, debug=False, egg=False, proj=None):
        self.debug = debug
        self.egg = egg
        self.proj = proj


DEBUG = True

USEPYX = False

if 'DEBUG_MODE' in os.environ:
    DEBUG = True

if USEPYX:
    import pyximport

    pyximport.install(language_level=3)

# --remote-debugging-port=8081

if __name__ == '__main__':
    if DEBUG:
        autoui_path = 'auto_ui'
        build_uidir('ui_file', autoui_path)
    from huza.base.mainwindow_run import MainWindowRun
    from handler import *
    from util.version import *

    extra = Extra(debug=DEBUG)
    app = MainWindowRun(extra)
    app.set_window_logo(app.icon_list.default.Targettrackingettings549)
    if DEBUG:
        app.set_window_title(f'{APPNAME} (debug model)-Ver{VERSION}')
    else:
        app.set_window_title(f'{APPNAME}-Ver{VERSION}')
    app.set_init_actions_func(init_actions)
    app.set_init_menu_func(init_menu)
    app.set_init_docks_func(init_docks)
    app.set_init_connect_func(init_connect)
    app.set_init_signal_func(init_signal)
    app.set_close_func(lambda _: None, loc=0b000)
    app.run()
